<span class="glyphicon glyphicon-map-marker" aria-hidden="true">
    <span>系统</span> /
    <span>物流配送</span> /
    <span>物流配送列表</span>
</span>
<div style="width: 100%;margin-top: 20px;">
    <div style="display:flex;width:100%;min-width:800px;">
        <div class="layui-tab layui-tab-card" style="width:100%;">

            <ul class="layui-tab-title">
                <li class="layui-this" style="width:50%;">物流配送列表</li>
                <li style="width:50%;">物流运费设置</li>
            </ul>

            <div class="layui-tab-content" style="height: auto;">

                <div class="layui-tab-item layui-show">

                    <table class="table table-hover"  border="1" width="100%" cellpadding="0" cellspacing="0" style="margin: 20px 0px;">
                        <tr>
                            <td width="20%" style="vertical-align: middle;">id编号</td>
                            <td width="40%" style="vertical-align: middle;">物流公司</td>
                            <td width="40%" style="vertical-align: middle;">是否启用</td>
                        </tr>
                        {volist name="list" id="vo"}
                        <tr>
                            <td style="vertical-align:middle;">{$vo.id}</td>
                            <td style="vertical-align:middle;">{$vo.com}</td>
                            <td style="vertical-align:middle;">
                                <div class='search_checkbox'>
                                    <input type='checkbox' id= 'status{$vo.id}' <?php if($vo['status'] == 0) { ?> checked <?php } ?> />
                                    <label for='status{$vo.id}'></label>
                                </div>
                                <script>
                                    $(document).on("click", "#status{$vo.id}", function() {
                                        var ch = $(this).is(":checked");
                                        if (ch) {
                                            getStatus({$vo.id},0);
                                        } else {
                                            getStatus({$vo.id},1);
                                        }
                                    });
                                </script>
                            </td>
                        </tr>
                        {/volist}
                    </table>

                    <div class="pagination">
                        {$list -> render();}
                    </div>
                </div>

                <div class="layui-tab-item">
                    <form class="form-horizontal" id="form">
                        <div class="form-group">
                            <label for="price" class="col-md-2 control-label">
                                <div class="text-center">快递运费:</div>
                            </label>
                            <div class="col-md-5">
                                <div class="input-group">
                                    <input type="number" class="form-control" id="price"
                                           name="price" value="{$freight.price}" placeholder="快递运费">
                                    <span class="input-group-addon">元</span>
                                </div>
                                <p style="color: #999999;">该商户下须邮费订单,快递运费全部统一价格</p>
                            </div>
                        </div>
                        <div class="form-group save-btn" style="width: 79%;">
                            <a href="JavaScript:index();" class="ncap-btn-big ncap-btn-green" style="background-color: #00a0e9;">提交</a>
                            <a href="JavaScript:void(0);" class="ncap-btn-big ncap-btn-green" onclick="history.go(-1)">返回</a>
                        </div>
                    </form>
                </div>

            </div>
        </div>
    </div>
</div>
<script src="__JS__/layui/layui.js" charset="UTF-8"></script>
<script type="text/javascript">
    layui.use('element', function(){
        var $ = layui.jquery
                ,element = layui.element; //Tab的切换功能，切换事件监听等，需要依赖element模块
    });
    function getStatus(id,status) {
        var json = {id:id,status:status};
        $.ajax({
            type:"post",
            url:"{:url('admin/Express/status')}",
            data:json,
            success:function (res) {
            }
        });
    }
    //物流运费设置
    function index(){
        var price = $("#price").val();
        if (price < 0) {
            error("快递运费必须大于等于0");
            return;
        }
        $.ajax({
            type:"post",
            url:"{:url('Admin/Express/Index')}",
            data:{price:price},
            success:function (res) {
                if (res == "设置成功") {
                    success(res);
                } else {
                    error(res);
                }
            }
        });
    }
</script>